<?php
class Zend_View_Helper_LoginMenu extends Zend_View_Helper_Abstract{
	public function loginMenu(){
		$auth = Zend_Auth::getInstance();
		$links = array();
		if($auth->hasIdentity()){
			$user = $auth->getIdentity();
			$logout = $this->view->url(array('controller'=>'login','action'=>'logout'),'default',true);
			if($user->role === 'admin'){
				$adminPanel = $this->view->url(array('module'=>'admin','controller'=>'index','action'=>'index'),'default',true);
				$links[] = '<a href="'.$adminPanel.'">Admin Panel</a>
				';
			}
			$links[] = '<a href="'.$logout.'">Log out</a>
			';
		} else {
			$links[] = '<a href="'.$this->view->url(array('controller'=>'login'),null,true).'">Log in</a>
			';
			$links[] = '<a href="'.$this->view->url(array('controller'=>'register'),null,true).'">Register</a>
			';
		}
		return $links;
	}
}